@echo off
setlocal

timeout /t 3 /nobreak

set "targetFolder=."
set "sourceFolder=%USERPROFILE%\Documents\MultiAgents\update\net8.0-windows10.0.19041.0\win-x64"
set "keepFile=updater.bat"

for %%F in ("%sourceFolder%\*") do (
    if /I not "%%~nxF"=="%keepFile%" (
        xcopy /Y "%%F" "%targetFolder%\"
    )
)

PowerShell -Command "Add-Type -AssemblyName Microsoft.VisualBasic; Add-Type -AssemblyName System.Windows.Forms; [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory('%USERPROFILE%\Documents\MultiAgents\update', [Microsoft.VisualBasic.FileIO.UIOption]::OnlyErrorDialogs, [Microsoft.VisualBasic.FileIO.RecycleOption]::SendToRecycleBin)"

start "" "%targetFolder%\MultiAgentsClient.Windows.exe"

endlocal
